package com.shitou.test.service;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shitou.pojo.User;
import com.shitou.service.UserService;

import junit.framework.TestCase;

public class UserServiceTestCase extends TestCase {
	private ApplicationContext ctx;
	private UserService userService;
	
	@Override
	protected void setUp() throws Exception {
		ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
		userService = (UserService) ctx.getBean("userService");
	}
	
	public void testFindById() {
		User user = userService.findById(1);
		assertEquals("tom", user.getName());
	}
	
	public void testLogin() {
		User user = new User();
		user.setName("admin");
		user.setPassword("000000");
		User u2 = userService.login(user);
		assertNotNull(u2);
	}
}
